﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="apple-itunes-app" content="app-id=591578609">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width"/>
<meta name="description" content="筑学堂网校" />
<meta name="keywords" content="筑学堂网校、建筑、考试"/>
<link href="http://www.zhuclass.com/img/icon.ico" type="image/x-icon" rel="icon"  />
<link href="http://www.zhuclass.com/img/icon.ico" type="image/x-icon" rel="shortcut icon"  />
<link rel="stylesheet" type="text/css" href="../../style/share/style.css">
<link rel="stylesheet" type="text/css" href="../../style/share/kczx.css">
<link rel="stylesheet" type="text/css" href="../../style/share/home_style.css">
<link rel="stylesheet" type="text/css" href="../../style/user.css">


<script type="text/javascript" src="../../js/home.js"></script>


<title>筑学堂家园个人空间</title>

<style type="text/css">
</style>

<script type="text/javascript">

   var editor;
 
   //群话题--更多
   function topicMore(){
	   $.ajax({ url: "../query_group_topic/${group_id}/1/null", 
	       success: function(result){
              $("#mainPageDiv").html(result);
           }
       });
   }
   //群共享--更多
   function shareMore(){
	   $.ajax({ url: "../query_group_share/${group_id}/1/null", 
	       success: function(result){
              $("#mainPageDiv").html(result);
           }
       });
   }
   
   //群动态--更多
   function dynamicMore(){
	   $.ajax({ url: "../query_group_dynamic/${group_id}", 
	       success: function(result){
              $("#mainPageDiv").html(result);
           }
       });
   }
   //添加成员和保存公告按钮事件
   function addMember(){
	     var flag =  $("#notice_a_link").attr("flag");
	     if("add"==flag){
	    	 var isMember = '${member}';
	    	 var isCreater = '${creater}';
	    	 if(isMember != 1 && isCreater !=1){
	    		 alert('请先加入群组！');
	    		 return;
	    	 }
	    	 $.ajax({ url: "../query_homeGroup_member_add_page/${group_id}", 
			       success: function(result){
		              $("#mainPageDiv").html(result);
		           }
		     });
	     }else if("edit"==flag){
	    	 
	    	//保存编辑好的通知
	         var url = "../query_homeGroup_member_edit_notice";
	         
	    	 var txt = editor.html();
	         
	    	  $.ajax({ url:url , 
	    		    type:"post",
	    		    data:{
	    		    	group_id:'${group_id}',
	    		    	txt:txt
	    		    },
			       success: function(result){
			    	   $("#button_change").html("添加成员");
				       $("#notice_a_link").attr("flag","add");
			    	   $("#myEditor").html(result);
			    	   
		           }
		     }); 
	     }
			
	 } 
   
   //点击编辑按钮事件
   function edit_gg(){
	    if("add"==$("#notice_a_link").attr("flag")){
	    	$("#button_change").html("保存编辑");
	    	$("#notice_a_link").attr("flag","edit");

	    	var txt = $("#myEditor").html();
	    	
	    	
		    $("#myEditor").html('<textarea name="content" style="width:680px;height:50px;visibility:hidden;display: block;padding:0px;"></textarea>');
		    
		   
		   
	    	editor = KindEditor.create('textarea[name="content"]', {
				resizeType : 0,
				height:'30px',
				allowPreviewEmoticons : false,
				allowImageUpload : false,
				items : [
					'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
					'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
					'insertunorderedlist']
			});
	    	
	    	// $('textarea[name="content"]').html(txt);
	    	 
	    	 editor.html(txt);
		    
	    }

   }
 
   function downfile(file_id,name,share_id){
   	var url = "${downloadURL}"+file_id+"?fnm="+name;
   	window.location.href=url; 
   	$.ajax({ url: "../down_group_share/"+share_id, 
		       success: function(result){
	           }
	    });
   }
   
   function deleteShare(share_id){
   	$.ajax({ url: "../delete_group_share/"+share_id, 
		       success: function(result){
		    	   alert(result);
		    	   $.ajax({ url: "../query_group_share/${group_id}/1/null", 
		    	       success: function(result){
		                  $("#mainPageDiv").html(result);
		               }
		           });
	           }
	    });
   }
 	//群话题详细页面
	  function topicDetail(topic_id){
		 $.ajax({ url: "../query_homeGroup_topic_detail/"+topic_id, 
				 data:{
	 		    	creater:'${creater}',
	 		    	member:'${member}'
	 		    },
		       success: function(result){
	              $("#mainPageDiv").html(result);
	           }
	     });	
	 }
	//群共享详细页面
	  function shareDetail(){
		 $.ajax({ url: "../query_group_share/${group_id}/1/null", 
		       success: function(result){
	              $("#mainPageDiv").html(result);
	           }
	     });	
	 }
	  
</script>
</head>
<body style="align:center; padding:0;margin:0;clear:both; background-color:FFF;">

		
			<div class="home_groupnotice" style="min-height:20px;">
				<a href="#"  onclick="addMember()" flag="add" id="notice_a_link">
					<div class="pic_top02"  id = "button_change" style="position:relative;left:0px;top:10px;float:right;background-color:#209E85;color:#EEE"> 
					    	<img src="../../images/add.png"> 邀请成员
				    </div>
				</a>
			</div>
		
			<div class="home_groupnotice" style="min-height:60px;">
				<div class="home_grnottit"> 
				   <div style="position:relative;float:left;width:100px;">
				                群公告
				   </div>  
				   <c:if test="${user_id ==data.create_id}">
						<a href="#"> <span class="home_grnottitm" onclick="edit_gg()">编辑 </span> </a> 
				   </c:if>
				</div>
			   <div class="home_groupnot" id="myEditor" style="width:680px;height:140px;padding-top: 5px;">
			       ${data.group_notice}
				</div>
				
				
			</div>
			<div class="home_groupnotice">
				<div class="home_grnottit"> <div style="position:relative;float:left;width:100px;">
				群话题</div>  <a href="#" onclick="topicMore()"> <span class="home_grnottitm">更多 </span></a> </div>
				<div class="home_groupnot" style="text-indent:1em;">
					<ul>
						<li style="background-color:#B3DDDF;">
							<ul style="width:100%;height:auto;">
								<li style="width:250px;"> 话题 </li>
								<li> 作者 </li>
								<li> 浏览 </li>
								<li> 回复 </li>
								<li> 最新回复 </li>
							</ul>
						</li>
						
						<c:forEach items="${dataTopic}" var="li">
							<li>
								<ul style="width:100%;height:auto;">
									<a href="#" onclick="topicDetail('${li.id}')">
									<li style="width:250px;">${li.topic_nm}</li></a>
									<li> ${li.create_nm} 
									     <c:if test="${li.create_nm=='' ||li.create_nm == null }">
									                  作者不详
									     </c:if>
									</li>
									<li> ${li.view_cnt} </li>
									<li> ${li.reply_cnt} </li>
									<li> ${li.last_reply_nm}
									    <c:if test="${li.last_reply_nm=='' ||li.last_reply_nm == null }">
									                      无最新回复
									     </c:if>
									 </li>
								</ul>
							</li>
						</c:forEach>
					</ul>
				</div>
			</div>
			<div class="home_groupnotice">
				<div class="home_grnottit"> 
				<div style="position:relative;float:left;width:100px;">
				群共享</div> <a href="#" onclick="shareMore()"> <div class="home_grnottitm">更多 </div> </a> </div>
				<div class="home_groupnot">
				<c:forEach items="${dataShar}" var="li">
					<div class="zyzx_more_zt01">
						<table class="zyzx_more_tab01">
							<tbody>
								<tr>
									<td height="15px" width="600px"> </td>
								</tr>
								<tr>
									<td height="25px" style="font-size:14px;font-weight:bold;"> <a href="#" onclick="shareDetail()"> <img src="../../images/zyzx_images/word.png">${li.topic} </a> </td>
									<td rowspan="3"> <a href="#" onclick="downfile('${li.file_id}','${li.name}',${li.share_id})">
										<div class="share_xz01" style="background-color:#F39C4F;">
											<div class="share_xz02"> ${li.down_cnt} </div>
											下&nbsp;载 </div>
										</a> </td>
								</tr>
								<tr>
									<td height="25px" style="color:#888;"> 大小：${li.file_size} 
										&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#333;"> 标签：</span>${li.tag_id} </td>
								</tr>
								<tr>
									<td height="25px"> <a href="#"> ${li.author_id}</a> 上传于${li.create_dt}&nbsp;&nbsp;
										&nbsp;&nbsp;&nbsp;&nbsp; 
										<a href="#"> 
										<img src="../../images/zyzx_images/ping.png"> 评论${li.comment_cnt} </a> &nbsp;&nbsp;&nbsp;&nbsp; 
										<a href="#"> <img src="../../images/zyzx_images/liu.png"> 点击${li.view_cnt} </a> &nbsp;&nbsp;&nbsp;&nbsp; 
										<!--<a href="#" onclick="shareMore()"> 编辑 </a>&nbsp; --> 
										<c:if test="${li.author_id}==${userId}">
											<a href="#" onclick="deleteShare(${li.share_id})"> 删除 </a> 
										</c:if>
										</td>
								</tr>
							</tbody>
						</table>
					</div>
				</c:forEach>
				</div>
			</div>
			<div class="home_groupnotice">
				<div class="home_grnottit"> <div style="position:relative;float:left;width:100px;">
				群动态</div>  <a href="#" onclick="dynamicMore()"> <span class="home_grnottitm">更多 </span> </a> </div>
				<ul class="user_li">
				  <c:forEach items="${dataDynamic}" var="li">
				  	 <c:if test="${li.dynamic_tp == 1}">
				     	 <li> &nbsp;&nbsp; <img src="../../images/dtjy.png"/> <a href="#">${li.sponsor_nm}</a> 和 <a href="#">${li.adopt_nm}</a> ${li.content} ${li.publish_dt} </li>
				 	 </c:if>
				 	 <c:if test="${li.dynamic_tp == 2}">
				     	 <li> &nbsp;&nbsp; <img src="../../images/dtjy.png"/> <a href="#">${li.sponsor_nm}</a> ${li.content} <a href="#">${li.adopt_nm}</a> ${li.publish_dt} </li>
				 	 </c:if>
				 	  <c:if test="${li.dynamic_tp == 3}">
				     	 <li> &nbsp;&nbsp; <img src="../../images/dtjy.png"/> <a href="#">${li.sponsor_nm}</a> ${li.content} </li>
				 	 </c:if>
				  </c:forEach>
				</ul>
			</div>

</body>
</html>